#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <signal.h>


void* run_task(void* arg);

int main()
{
    pthread_t pth;
    pthread_create(&pth, NULL, run_task, NULL);

    while(1) {
        printf("[0x%x] main task running.\n", pthread_self());
        sleep(2);
    }

    return 0;
}


void* run_task(void* arg)
{
    extern void sigroutine(int dunno);
    signal(SIGINT, sigroutine);
    signal(SIGSEGV, sigroutine);

    while(1) {
        printf("[0x%x] thread task running.\n", pthread_self());
        sleep(2);
    }
}


void sigroutine(int dunno)
{
    printf("[0x%x] sigroutine.\n", pthread_self());
    switch(dunno)
    {
        case SIGINT:
        case SIGSEGV:
        {
            printf("[0x%x] Signal SIGSEGV/SIGINT.\n", pthread_self());
        }
        break;
    }

}
